package com.bay1ts.controller;

import com.bay1ts.service.GoverService;
import com.bay1ts.service.RequestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.*;

/**
 * Created by chenuu on 2016/4/2.
 */
@Controller
@RequestMapping("gover")
public class GoverController {
    @Autowired
    private GoverService goverService;
    @Autowired
    private RequestService requestService;
    //检查所有申请，已经通过的
    @RequestMapping(value = "getallowed")
    public void getAllowed(){
        Map<String, List> map= requestService.getApplyDetailsSortByType(goverService.getResult(1));
    }
    //检查所有申请，已经失败的
    @RequestMapping(value = "getfailed")
    public void getFailed(){
        Map<String, List> map= requestService.getApplyDetailsSortByType(goverService.getResult(0));
    }
    //拒绝申请(已通过的)
    @RequestMapping(value = "rejectrequest")
    public void rejectRequest(Long id,String comment){
        Map<Long,String> map=new HashMap<Long, String>();
        map.put(id,comment);
        requestService.rejectRequest(map);
    }
    //最终通过
    @RequestMapping(value = "passrequest")
    public void passRequest(Long id){
        List<Long> ids=new ArrayList<Long>();
        ids.add(id);
        requestService.finalPassRequest(ids);
        //加学分逻辑
        goverService.addCredit(id);
    }
    @RequestMapping(value = "output")
    //type 0表示三种 1表示 subject，2表示entreperneurship,3表示vocationa。。
    public void output(int type, Date fromDate,Date toDate){

    }
}
